package com.jiuwu.spring.eshop.respository;

import com.jiuwu.spring.eshop.db.entity.SubType;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

public interface SubTypeRepository extends JpaRepository<SubType,Integer> {


    @Query(value = "select  tb_subType.ID as ID ,P.typeName as superType,tb_subType.typeName as subType  from tb_subType " +
            "left join tb_superType AS P on tb_subType.superType = P.ID order by ID Desc",nativeQuery = true)
    List<Object[]> findAllSuperComSub();


    /**
     * 通过 superType 查询所有子类型
     * @param superType
     * @return
     */
    List<SubType> findAllBySuperTypeEquals(int superType);



}
